function $$(id) {
	return document.getElementById(id);
}

var uploaderf = new plupload.Uploader({
	multi_selection : false,
	runtimes : 'gears,html5,html4,flash,silverlight,browserplus',
	browse_button : 'pickfilesf',
	container: 'containerf',
	max_file_size : '100mb',
	url : '/dev-api/upload/UploadFujian',
	// url : '/prod-api/upload/UploadFujian',
	// url : '/api/upload/UploadFujian',
	//resize : {width : 320, height : 240, quality : 90},
	flash_swf_url : '../js/plupload/plupload.flash.swf',
	silverlight_xap_url : '../js/plupload/plupload.silverlight.xap',
	filters : [
		{title : "Image files", extensions : "rar,zip,doc,docx,pdf,mp3,xls,xlsx,chm,ppt,pptx,avi,rmvb,wmv,flv,swf,rm,exe,psd,txt,mp4"}
	]
});

function InitUpLoaderf()
{
	uploaderf.bind('Init', function(up, params) {
		$$('filelistf').innerHTML = "";
	});

	uploaderf.init();

	uploaderf.bind('FilesAdded', function(up, files) {

		for ( var i in files) {
			$$('filelistf').innerHTML = '<span id="' + files[i].id + '">'
					+ files[i].name + ' (' + plupload.formatSize(files[i].size)
					+ ') <b></b></span>';
		}
		uploaderf.start();
	});

	uploaderf.bind('UploadProgress', function(up, file) {
		$$(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
	});

	uploaderf.bind('FileUploaded', function(up, file, response) {
		var mmResponse = (response.response).replace(/\\/g, "").replace(/(")/g, "");
	    var mmFileUrl = mmResponse;
	    $("#fujianurl").val(mmFileUrl);

	    var a = mmFileUrl.split(".");
	    var type = a[1];

	    file.value = unescape(mmFileUrl);

	    var mmHtml = "<div class='progressWrapper' id='SWFUploaded_0_0' style='opacity:1'><div class='progressContainer blue'>" +
	    		"<a class='progressCancel' href='#' style='visible;' title='从成功队列中移除'></a>" +
	    		"<div class='progressName'>" + file.name + "</div><div class='progressBarStatus'><span style='color:#0b0;font-weight:bold;'>上传成功！</span></div>" +
	    				"<div class='progressBarComplete' style></div></div></div>";

	    $("#fsUploadProgress").html(mmHtml);

	    var map = fileTypeMaps;

        var src = editor.options.UEDITOR_HOME_URL + "dialogs/attachment/fileTypeImages/"+(map["."+type]||"icon_default.png");

	//    var str = "<video src='"+ mmFileUrl +"' type='video/mp4' autoplay='autoplay' width='720' height='400' controls='controls' ></video>";
	   var str = "<audio controls='controls'><source src='"+ mmFileUrl +"' type='audio/mpeg'><embed height='100' width='100' src='"+ mmFileUrl +"' /> </audio>";
		// var str = "<p style='line-height: 16px;'><img src='"+ src + "' _src='"+src+"' />" +
        // "<a href='"+ mmFileUrl +"'>" + file.name + "</a></p>";


	    editor.execCommand("insertHTML",str);

	});
	uploaderf.bind('Error', function(up, err) {
	    //alert("Error #" + err.code + ": " + err.message);
	});
}

